<?php

namespace app\controller;

use app\BaseController;

class Index extends BaseController
{
    public function index()
    {
        return 'hello,';
    }
    public function login(Request $request)
    {
        $username = $request->post('userName');
        $password = $request->post('password');
        $serverid = $request->post('serverId');
        
        $url = 'http://23.225.71.125:8802/wuquan/userApi/userLogin';
         $data = json_encode([
             'deviceId' => '51db71d3_03ec_465e_9cd3_58f6f2280c82',
             'identify' => '51db71d3_03ec_465e_9cd3_58f6f2280c82',
             'password'  => "{$password}",
             'serverId'  => "{$serverid}",
             'userName'  => "{$username}",
             'type' => '1',
             
         ]);
          
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);                                                                  
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
         curl_setopt($ch, CURLOPT_HTTPHEADER, [                                                                          
             'Content-Type: application/json',                                                                     
             'Content-Length: ' . strlen($data)                                                                      
         ]);                                                                                                            
         $result = curl_exec($ch);
         curl_close($ch);
         echo $result; // 输出结果
    }

}
